/**
 * Copyright &copy; 2012-2016 <a href="https://www.kaaction.com">KAA</a> All rights reserved.
 */
package com.kaaction.modules.operate.api;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.kaaction.common.web.BaseController;
import com.kaaction.modules.operate.entity.Material;
import com.kaaction.modules.operate.service.ClientMaterialService;
import com.kaaction.modules.operate.service.ClientService;
import com.kaaction.modules.operate.service.MaterialService;

/**
 * 客户Controller
 * @author zengbiao
 * @version 2017-04-13
 */
@Controller
@RequestMapping(value = "/api/v1/operate/material")
public class MaterialApiController extends BaseController {

	@Autowired
	private ClientService clientService;
	
	@Autowired
	private MaterialService materialService;
	
	@Autowired
	private ClientMaterialService clientMaterialService;
	
	@RequestMapping(value = {"list"})
	public void add(HttpServletRequest request, HttpServletResponse response) throws IOException {
		response.setHeader("Access-Control-Allow-Origin", "*");
		PrintWriter pw = response.getWriter();
		
		List<Material> materialList =  materialService.findList(new Material());
		pw.write(JSON.toJSONString(materialList,SerializerFeature.DisableCircularReferenceDetect));
		
		pw.flush();
		pw.close();
	}

}